#ifndef VM_PAGE_H
#define VM_PAGE_H
#include "stdbool.h"
#include "stdint.h"
#include "hash.h"

struct page
{
	//upage value
	void *upage;
	int swap_position;
	struct thread *t;
	struct hash_elem hash_elem;

	// for project 3-2
	struct file *fp;
	int32_t offset;
	int readbyte;
	bool writable;
	bool isLoaded;
};

bool page_init(void);
void page_deallocate(struct thread *);

unsigned page_hash (const struct hash_elem *p_, void *aux);
bool page_less (const struct hash_elem *a_, const struct hash_elem *b_, void *aux);
/* Returns the page containing the given virtual address,
 * or a null pointer if no such page exists. */
struct page * page_lookup (void *upage, struct thread *t);
void hash_destructor(struct hash_elem *h_elem,void *aux);


bool page_insert(void *, void *, bool );


// for project 3-2
bool lazy_page_insert(void *upage, bool writable, struct file *f, int32_t offset, int readbyte);

#endif
